package delete;

import java.io.File;
import java.util.Scanner;

public class Delete {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s;
		System.out.println("请输入e盘一个文件夹名称；");
		s = in.nextLine();

		File[] fs = File.listRoots();
		File[] fs1 = fs[2].listFiles();
		for (int i = 0; i < fs1.length; i++) {
			if (fs1[i].getName().toString().contains(s)) {
				File[] fs2 = fs1[i].listFiles();
				for (int j = 0; j < fs2.length; j++) {
					if (fs2[j].isDirectory()) {
						enter(fs2[j]);
						fs2[j].delete();
					} else
						fs2[j].delete();
				}
			}
		}
		in.close();
	}

	public static void enter(File fs2) {
		File[] fs = fs2.listFiles();
		for (int i = 0; i < fs.length; i++) {
			if (fs[i].isFile() || fs.length == 0)
				fs[i].delete();
			else {
				enter(fs[i]);
				fs[i].delete();
			}
		}
	}
}
